package com.bytedance.common.plugin.interfaces.pushmanager.setting;

import android.content.Context;
import android.support.design.a;
import android.util.Pair;

import com.bytedance.common.plugin.interfaces.pushmanager.setting.PushMultiProcessSharedProvider.Editor;
import com.bytedance.common.plugin.interfaces.pushmanager.setting.PushMultiProcessSharedProvider.MultiProcessShared;
import com.bytedance.common.utility.Logger;

import org.json.JSONObject;

import java.util.Iterator;
import java.util.Map;

public class PushSetting {
    public static final String ALI_PUSH_TYPE = "ali_push_type";
    public static final String ALLOW_CLOSE_BOOT_RECEIVER = "allow_close_boot_receiver";
    public static final String ALLOW_NETWORK = "allow_network";
    public static final String ALLOW_OFF_ALIVE = "allow_off_alive";
    public static final String ALLOW_PUSH_DAEMON_MONITOR = "allow_push_daemon_monitor";
    public static final String ALLOW_PUSH_JOB_SERVICE = "allow_push_job_service";
    public static final String ALLOW_SELF_PUSH_ENABLE = "allow_self_push_enable";
    public static final String ALLOW_SETTINGS_NOTIFY_ENABLE = "allow_settings_notify_enable";
    public static final String IS_CLOSE_ALARM_WAKEUP = "is_close_alarm_wakeup";
    public static final String IS_SEND_MZ_MESSAGE_ARRIVE_DATA = "is_send_mz_message_receiver_data";
    public static final String KEY_LAST_SCHEDULED_TIME = "last_scheduled_time";
    public static final String KEY_PUSH_APPS = "push_apps";
    public static final String LAST_GET_UPDATE_SENDER_TIME_MIL = "last_get_update_sender_time_mil";
    public static final String LAST_SEND_NOTIFY_ENABLE_IS_SUCC = "last_send_notify_enable_is_succ";
    public static final String LOC = "loc";
    public static final String MESSAGE_CACHE_LIST = "message_cache_list";
    public static final String PUSH_CHANNELS_JSON_ARRAY = "push_channels_json_array";
    public static final String PUSH_DAEMON_MONITOR = "push_daemon_monitor";
    public static final String PUSH_DAEMON_MONITOR_RESULT = "push_daemon_monitor_result";
    public static final String PUSH_NOTIFY_ENABLE = "push_notify_enable";
    public static final String PUSH_REGISTER_RESULTS = "push_register_results";
    public static final String SELF_PUSH_MESSAGE_IDS = "self_push_message_ids";
    public static final String SHUT_PUSH_ON_STOP_SERVICE = "shut_push_on_stop_service";
    public static final String SYSTEM_PUSH_ENABLE = "system_push_enable";
    public static final String UNINSTALL_QUESTION_URL = "uninstall_question_url";
    public static final String UPDATE_SENDER_INTERVAL_TIME_SECOND = "update_sender_interval_time_second";
    public static final String WAKEUP_BLACK_LIST_PACKAGE = "wakeup_black_list_package";
    private Context mContext;
    private MultiProcessShared multiProcessShared;
    private static PushSetting sPushSetting;

    private PushSetting(Context arg2) {

        this.mContext = arg2.getApplicationContext();
        this.multiProcessShared = PushMultiProcessSharedProvider.getMultiprocessShared(this.mContext);
    }

    public int getAliPushType() {
        return this.multiProcessShared.getInt("ali_push_type", -1);
    }

    public String getDeviceId() {
        return PushCommonSetting.getInstance().getDeviceId();
    }

    public static PushSetting getInstance() {
        PushSetting v0_1;
        Class v1 = PushSetting.class;
        synchronized (v1) {
            if (PushSetting.sPushSetting == null) {
                throw new IllegalStateException("PushSetting not init");
            }

            v0_1 = PushSetting.sPushSetting;
        }
        return v0_1;
    }

    public long getLastGetUpdateSenderTimeMil() {
        return this.multiProcessShared.getLong("last_get_update_sender_time_mil", 0);
    }

    public String getLoc() {
        return this.multiProcessShared.getString("loc", "");
    }

    public Pair getLocPair() {
        Pair v0 = null;
        if (Logger.debug()) {
            Logger.d("PushService", "getLoc start");
        }

        try {
            String v1_1 = this.getLoc();
            if (Logger.debug()) {
                Logger.d("PushService", "getLoc = " + v1_1);
            }

            if (a.isTextEmpty(v1_1)) {
                return v0;
            }

            JSONObject v2 = new JSONObject(v1_1);
            Double.valueOf(0);
            Double.valueOf(0);
            v0 = new Pair(Double.valueOf(v2.optDouble("lon")), Double.valueOf(v2.optDouble("lat")));
        } catch (Exception v1) {
        }

        return v0;
    }

    public Boolean getProviderBoolean(String arg3, Boolean arg4) {
        return Boolean.valueOf(this.multiProcessShared.getBoolean(arg3, arg4.booleanValue()));
    }

    public int getProviderInt(String arg2, int arg3) {
        return this.multiProcessShared.getInt(arg2, arg3);
    }

    public long getProviderLong(String arg3, long arg4) {
        return this.multiProcessShared.getLong(arg3, arg4);
    }

    public String getProviderString(String arg2, String arg3) {
        return this.multiProcessShared.getString(arg2, arg3);
    }

    public String getPushAppsString() {
        return this.multiProcessShared.getString("push_apps", "");
    }

    public String getPushChannelsJsonArray() {
        return this.multiProcessShared.getString("push_channels_json_array", "");
    }

    public String getPushDaemonMonitor() {
        return this.multiProcessShared.getString("push_daemon_monitor", "");
    }

    public String getPushDaemonMonitorResult() {
        return this.multiProcessShared.getString("push_daemon_monitor_result", "");
    }

    public String getPushRegisterResults() {
        return this.multiProcessShared.getString("push_register_results", "");
    }

    public void getSSIDs(Map arg2) {
        PushCommonSetting.getInstance().getSSIDs(arg2);
    }

    public String getSelfPushMessageIds() {
        return this.multiProcessShared.getString("self_push_message_ids", "");
    }

    public String getSsids() {
        return PushCommonSetting.getInstance().getSsids();
    }

    public int getSystemPushEnable() {
        return this.multiProcessShared.getInt("system_push_enable", -2);
    }

    public String getUninstallQuestionUrl() {
        return this.multiProcessShared.getString("uninstall_question_url", "");
    }

    public int getUpdateSenderIntervalTimeSecond() {
        return this.multiProcessShared.getInt("update_sender_interval_time_second", 10800);
    }

    public String getWakeupBlackListPackages() {
        return this.multiProcessShared.getString("wakeup_black_list_package", "");
    }

    public long gutLastScheduledTime() {
        return this.multiProcessShared.getLong("last_scheduled_time", 0);
    }

    public static void init(Context arg2) {
        Class v1 = PushSetting.class;
        synchronized (v1) {
            if (PushSetting.sPushSetting == null) {
                PushSetting.sPushSetting = new PushSetting(arg2);
            }

            PushCommonSetting.init(arg2);
        }
    }

    public boolean isAllowCloseBootReceiver() {
        return this.multiProcessShared.getBoolean("allow_close_boot_receiver", true);
    }

    public boolean isAllowNetwork() {
        return this.multiProcessShared.getBoolean("allow_network", true);
    }

    public boolean isAllowOffAlive() {
        return this.multiProcessShared.getBoolean("allow_off_alive", true);
    }

    public boolean isAllowPushDaemonMonitor() {
        return this.multiProcessShared.getBoolean("allow_push_daemon_monitor", true);
    }

    public boolean isAllowPushJobService() {
        return this.multiProcessShared.getBoolean("allow_push_job_service", true);
    }

    public boolean isAllowSelfPushEnable() {
        boolean v0 = false;
        if ((this.multiProcessShared.getBoolean("allow_self_push_enable", false)) && (this.isPushNotifyEnable())) {
            v0 = true;
        }

        return v0;
    }

    public boolean isAllowSettingsNotifyEnable() {
        return this.multiProcessShared.getBoolean("allow_settings_notify_enable", true);
    }

    public boolean isCloseAlarmWakeUp() {
        return this.multiProcessShared.getBoolean("is_close_alarm_wakeup", false);
    }

    public boolean isLastSendNotifyEnableSucc() {
        return this.multiProcessShared.getBoolean("last_send_notify_enable_is_succ", true);
    }

    public boolean isPushNotifyEnable() {
        boolean v0 = true;
        if (!this.multiProcessShared.getBoolean("push_notify_enable", true) || !this.isAllowSettingsNotifyEnable()) {
            v0 = false;
        }

        return v0;
    }

    public boolean isSendMzMessageArriveData() {
        return this.multiProcessShared.getBoolean("is_send_mz_message_receiver_data", false);
    }

    public boolean isShutPushNotifyEnable() {
        boolean v0 = (this.isPushNotifyEnable()) || !this.isShutPushOnStopService() ? false : true;
        return v0;
    }

    public boolean isShutPushOnStopService() {
        return this.multiProcessShared.getBoolean("shut_push_on_stop_service", false);
    }

    public void saveMapToProvider(Map arg7) {
        try {
            Editor v2 = this.multiProcessShared.edit();
            if (arg7 != null) {
                Iterator v3 = arg7.entrySet().iterator();
                while (v3.hasNext()) {
                    Object v0_1 = v3.next();
                    Object v1 = ((Map.Entry) v0_1).getValue();
                    if ((v1 instanceof Integer)) {
                        v2.putInt((String) ((Map.Entry) v0_1).getKey(), ((Integer) v1).intValue());
                        continue;
                    }

                    if ((v1 instanceof Long)) {
                        v2.putLong((String) ((Map.Entry) v0_1).getKey(), ((Long) v1).longValue());
                        continue;
                    }

                    if ((v1 instanceof Float)) {
                        v2.putFloat((String) ((Map.Entry) v0_1).getKey(), ((Float) v1).floatValue());
                        continue;
                    }

                    if ((v1 instanceof Boolean)) {
                        v2.putBoolean((String) ((Map.Entry) v0_1).getKey(), ((Boolean) v1).booleanValue());
                        continue;
                    }

                    if (!(v1 instanceof String)) {
                        continue;
                    }

                    v2.putString((String) ((Map.Entry) v0_1).getKey(), ((String) v1));
                }

                v2.commit();
            }

            return;
        } catch (Throwable v0) {
            return;
        }
    }

    public void saveSSIDs(Map arg2) {
        PushCommonSetting.getInstance().saveSSIDs(arg2);
    }

    public void setAliPushType(int arg3) {
        this.multiProcessShared.edit().putInt("ali_push_type", arg3).apply();
    }

    public void setAllowCloseBootReceiver(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("allow_close_boot_receiver", arg3).apply();
    }

    public void setAllowOffAlive(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("allow_off_alive", arg3).apply();
    }

    public void setAllowPushDaemonMonitor(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("allow_push_daemon_monitor", arg3).apply();
    }

    public void setAllowPushJobService(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("allow_push_job_service", arg3).apply();
    }

    public void setAllowSelfPushEnable(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("allow_self_push_enable", arg3).apply();
    }

    public void setAllowSettingsNotifyEnable(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("allow_settings_notify_enable", arg3).apply();
    }

    public void setIsAllowNetwork(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("allow_network", arg3).apply();
    }

    public void setIsCloseAlarmWakeup(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("is_close_alarm_wakeup", arg3).apply();
    }

    public void setIsSendMzMessageArriveData(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("is_send_mz_message_receiver_data", arg3).apply();
    }

    public void setIsShutPushOnStopService(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("shut_push_on_stop_service", arg3).apply();
    }

    public void setLastGetUpdateSenderTimeMil(long arg4) {
        this.multiProcessShared.edit().putLong("last_get_update_sender_time_mil", arg4).apply();
    }

    public void setLastSendNotifyEnableSucc(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("last_send_notify_enable_is_succ", arg3).apply();
    }

    public void setLoc(String arg3) {
        this.multiProcessShared.edit().putString("loc", arg3).apply();
    }

    public void setPushApps(String arg3) {
        this.multiProcessShared.edit().putString("push_apps", arg3).apply();
    }

    public void setPushChannelsJsonArray(String arg3) {
        this.multiProcessShared.edit().putString("push_channels_json_array", arg3).apply();
    }

    public void setPushDaemonMonitor(String arg3) {
        this.multiProcessShared.edit().putString("push_daemon_monitor", arg3).apply();
    }

    public void setPushDaemonMonitorResult(String arg3) {
        this.multiProcessShared.edit().putString("push_daemon_monitor_result", arg3).apply();
    }

    public void setPushNotifyEnable(boolean arg3) {
        this.multiProcessShared.edit().putBoolean("push_notify_enable", arg3).apply();
    }

    public void setPushRegisterResults(String arg3) {
        this.multiProcessShared.edit().putString("push_register_results", arg3).apply();
    }

    public void setPutLastScheduledTime(long arg4) {
        this.multiProcessShared.edit().putLong("last_scheduled_time", arg4).apply();
    }

    public void setSelfPushMessageIds(String arg3) {
        this.multiProcessShared.edit().putString("self_push_message_ids", arg3).apply();
    }

    public void setSystemPushEnable(int arg3) {
        this.multiProcessShared.edit().putInt("system_push_enable", arg3).apply();
    }

    public void setUninstallQuestionUrl(String arg3) {
        this.multiProcessShared.edit().putString("uninstall_question_url", arg3).apply();
    }

    public void setUpdateSenderIntervalTimeSecond(int arg3) {
        this.multiProcessShared.edit().putInt("update_sender_interval_time_second", arg3).apply();
    }

    public void setWakeupBlackListPackages(String arg3) {
        this.multiProcessShared.edit().putString("wakeup_black_list_package", arg3).apply();
    }
}

